package com.etc.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.etc.dao.BlogMapper;
import com.etc.dao.LogMapper;
import com.etc.entity.Blog;
import com.etc.entity.Log;
import com.etc.service.BlogService;

@Service(value="blogService")
public class BlogServiceImpl implements BlogService{

	@Autowired
	private BlogMapper blogMapper;
	@Autowired
	private LogMapper logMapper;

	
	@Override
	public Blog getBlogById(int blogId) {
		// TODO Auto-generated method stub
		return blogMapper.selectByPrimaryKey(blogId);
	}
	

	
	@Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
	public boolean insertBlog(Blog blog) {
		
		Log log =new Log();
		log.setLogOp("insertBlog");
		int a =blogMapper.insert(blog);
		int b =logMapper.insert(log);
		return a>0 && b>0;
	}


}
